package com.heima.wemedia.controller;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.model.wemedia.dtos.SensitiveQueryDto;
import com.heima.model.wemedia.pojos.WmSensitive;
import com.heima.model.common.vos.PageResultVo;
import com.heima.wemedia.service.WmNewsSensitiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/api/vi/sensitive")
public class WmNewsSensitiveController {
    @Autowired
    private WmNewsSensitiveService wmNewsSensitiveService;

    /**
     * 删除敏感词
     * @param id 敏感词ID
     */
    @DeleteMapping("/del/{id}")
    public ResponseResult<String> delete(@PathVariable Integer id) {
        return wmNewsSensitiveService.delete(id);
    }

    /**
     * 查询敏感词
     * @param dto 查询参数
     */
    @PostMapping("/list")
    public ResponseResult<PageResultVo<WmSensitive>> list(@RequestBody SensitiveQueryDto dto) {
        return wmNewsSensitiveService.querySensitive(dto);
    }

    /**
     * 新增敏感词
     * @param wmSensitive 敏感词
     */
    @PostMapping("/save")
    ResponseResult<AppHttpCodeEnum> insert(@RequestBody WmSensitive wmSensitive){
        return wmNewsSensitiveService.insert(wmSensitive);
    }

    /**
     * 修改敏感词
     * @param wmSensitive 敏感词
     */
    @PostMapping("/update")
    ResponseResult<AppHttpCodeEnum> update(@RequestBody WmSensitive wmSensitive){
        return wmNewsSensitiveService.modify(wmSensitive);
    }
}
